/**
 * Created by Demon-pro on 2015/6/28.
 */
var Pipeline = function () {
    var saveValidate = function () {
        var E115 = $("#E115").val();
        if (E115 == "") {
            toast.error("单台磨出口送粉管道数量 不能为空")
            return false;
        }
        var E118 = $("#E118").val();
        if (E118 == "") {
            toast.error("煤粉管道外径 不能为空")
            return false;
        }
        var E119 = $("#E119").val();
        if (E119 == "") {
            toast.error("煤粉管道壁厚 不能为空")
            return false;
        }
        return true;
    }

    var getPipeline=function(){
        return{
            E115: $("#E115").val(),
            E118: $("#E118").val(),
            E119: $("#E119").val(),
            caseId: $("#caseId").val()
        }
    }

    return {
        pipelineSave: function () {
            if (!saveValidate())return;
            var addFlag = $("#addFlag").val();
            if (addFlag == "add" || (addFlag != "add" && confirm("确定重新计算并保存吗？"))) {
                Metronic.blockUI({
                    boxed: true,
                    message: "数据加载中..."
                });
                $.ajax({
                    url: basePath + "mill/pipe/pipelineSave",
                    type: "post",
                    dataType: "json",
                    data: getPipeline(),
                    success: function (data) {
                        Metronic.unblockUI();
                        if (data.ok) {
                            formSub(basePath + "mill/pipe?menuId=39&message=success")
                        } else if (data.error) {
                            toast.error(data.returnMsg);
                            return false;
                        }
                    }
                })
            }
        },
        pipelineNext: function () {
            var addFlag = $("#addFlag").val();
            if (addFlag == "add") {
                toast.error("请先填写本页数据，保存成功后再进行下一页操作！");
                return;
            }
            formSub(basePath + "mill/CoalPulverizingSystem?menuId=43")
        }
    }
}();
